package cn.edu.wfit.modules.system.controller;

import cn.edu.wfit.common.core.utils.AliOSSUtils;
import cn.edu.wfit.common.core.web.controller.BaseController;
import cn.edu.wfit.common.core.web.domain.AjaxResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
/**
 * oss上传
 *
 * @author ruoyi
 */
@RestController
@RequestMapping("/image")
public class

OssController extends BaseController {
    /**
     * 上传文件
     */
    @PostMapping
    public AjaxResult imageUpload(MultipartFile file) {
        AliOSSUtils aliOSSUtils = new AliOSSUtils();
        try {
            String url = aliOSSUtils.upload(file);
            return AjaxResult.success(url);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
